package com.idroid.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.widget.TextView;

import java.io.IOException;
import java.net.URL;

/**
 * 代码中TextView中的图片位置显示方法
 * Created by oushuhua
 */

public class TextDrawable {
    public static void drawable(Context ctx, TextView tv, int res, int position){
        Drawable drawable = ctx.getResources().getDrawable(res);
        drawable.setBounds(0,0,drawable.getMinimumWidth(),drawable.getMinimumHeight());
        if(position==0){
            tv.setCompoundDrawables(drawable, null, null, null);
        }else if(position==1){
            tv.setCompoundDrawables(null, drawable, null, null);
        }else if(position==2){
            tv.setCompoundDrawables(null, null, drawable, null);
        }else if(position==3){
            tv.setCompoundDrawables(null, null, null, drawable);
        }
    }

    public static void drawable(TextView tv,Drawable drawable , int position){
        //Drawable drawable = ctx.getResources().getDrawable(res);
        drawable.setBounds(0,0,drawable.getMinimumWidth(),drawable.getMinimumHeight());
        if(position==0){
            tv.setCompoundDrawables(drawable, null, null, null);
        }else if(position==1){
            tv.setCompoundDrawables(null, drawable, null, null);
        }else if(position==2){
            tv.setCompoundDrawables(null, null, drawable, null);
        }else if(position==3){
            tv.setCompoundDrawables(null, null, null, drawable);
        }
    }

}
